package cn.edu.scau.cmi.huangxiyan.hibernate.unit;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class SessionFactoryUnit {
	private static SessionFactory sf = null;

	@SuppressWarnings("deprecation")
	private static SessionFactory getSessionFactory() {
		if (sf == null) {
			sf = new Configuration().configure().buildSessionFactory();
		}

		return sf;
	}

	public static Session getSession() {
		return getSessionFactory().openSession();
	}

}
